Skip to content

[#12434] Add Node Interpolation#12506

Merged
emeroad merged 1 commit intopinpoint-apm:masterfrom
emeroad:#12434_no_node
May 28, 2025
Merged

[#12434] Add Node Interpolation#12506
emeroad merged 1 commit intopinpoint-apm:masterfrom
emeroad:#12434_no_node

Conversation

@emeroad
Copy link
Copy Markdown
Member

@emeroad emeroad commented May 28, 2025

This pull request refactors the MapServiceImpl class in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/MapServiceImpl.java to improve code readability and modularity. Key changes include introducing a new method for handling cases with no request data, simplifying method signatures, and modifying factory methods to accept boolean parameters instead of MapServiceOption.

Refactoring for improved modularity:

  • Introduced buildForNoRequest method: Added a private method to handle scenarios where no nodes are found in the application map, ensuring the map is still built with the source application. This improves readability and encapsulates logic.

Simplification of method signatures:

  • Refactored newNodeHistogramFactory method: Changed the method to accept a boolean parameter (isSimpleResponseHistogram) instead of the entire MapServiceOption object, simplifying its usage.
  • Refactored newServerGroupListFactory method: Updated the method to accept a boolean parameter (isUseStatisticsAgentState) instead of MapServiceOption, aligning with the changes made to newNodeHistogramFactory.

Code cleanup and minor adjustments:

  • Modified selectApplicationMap logic: Replaced direct calls to builder.build with the new buildForNoRequest method for handling empty nodes, improving clarity.
  • Added import for Application: Included the necessary import for the Application class to support the new buildForNoRequest method.

@emeroad emeroad added this to the 3.1.0 milestone May 28, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 33.58%. Comparing base (a3024f4) to head (5c66896).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...int/web/applicationmap/service/MapServiceImpl.java 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #12506   +/-   ##
=========================================
  Coverage     33.58%   33.58%           
- Complexity    10744    10746    +2     
=========================================
  Files          3941     3941           
  Lines         91887    91889    +2     
  Branches       9558     9558           
=========================================
+ Hits          30857    30859    +2     
- Misses        58387    58388    +1     
+ Partials       2643     2642    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emeroad emeroad requested a review from Copilot May 28, 2025 10:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors MapServiceImpl to improve readability and modularity by extracting special-case logic, simplifying factory method signatures, and cleaning up imports.

  • Introduces buildForNoRequest to handle empty-node scenarios in selectApplicationMap
  • Simplifies newNodeHistogramFactory and newServerGroupListFactory to take boolean flags instead of the full MapServiceOption
  • Updates selectApplicationMap to delegate to the new method for no-request cases
Comments suppressed due to low confidence (3)

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/MapServiceImpl.java:130

  • No new tests cover the buildForNoRequest path; consider adding a unit test to verify that an empty-node scenario produces the expected map with only the source application.
            map = buildForNoRequest(option.getSourceApplication(), builder);

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/MapServiceImpl.java:142

  • [nitpick] The parameter order (Application source, ApplicationMapBuilder builder) is inverted compared to other helpers; consider placing the builder parameter first for consistency with existing methods.
private ApplicationMap buildForNoRequest(Application source, ApplicationMapBuilder builder) {

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/MapServiceImpl.java:144

  • Since includeServerInfo is already called in createApplicationMapBuilder, this second call may add duplicate server info. Verify that re-inclusion is intended or clear previous server info before adding the fallback.
        builder.includeServerInfo(newServerGroupListFactory(false));


private ApplicationMap buildForNoRequest(Application source, ApplicationMapBuilder builder) {
// If no nodes are found, we still need to build the map with the source application.
builder.includeServerInfo(newServerGroupListFactory(false));
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a raw false literal makes the intent unclear; extract this flag into a well-named constant or consider overloading newServerGroupListFactory for readability.

Suggested change
builder.includeServerInfo(newServerGroupListFactory(false));
builder.includeServerInfo(newServerGroupListFactory(USE_STATISTICS_AGENT_STATE_FOR_NO_REQUEST));

Copilot uses AI. Check for mistakes.
@@ -138,19 +139,25 @@ public ApplicationMap selectApplicationMap(MapServiceOption option) {
return map;
}

Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a Javadoc comment to explain the purpose of buildForNoRequest and describe its parameters, since it encapsulates special-case behavior.

Suggested change
/**
* Builds an {@link ApplicationMap} for scenarios where no request data is available.
* This method ensures that the map is still constructed using the source application,
* even if no nodes are found.
*
* @param source The source application for which the map is being built.
* @param builder The {@link ApplicationMapBuilder} used to construct the map.
* @return The constructed {@link ApplicationMap}.
*/

Copilot uses AI. Check for mistakes.
@emeroad emeroad merged commit 5a46816 into pinpoint-apm:master May 28, 2025
4 of 5 checks passed
@emeroad emeroad deleted the #12434_no_node branch May 30, 2025 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants